< previous page page_426 next page >

Page 426
z0446-01.gif
Figure 13.2
Measuring angles of rotation.
Finally, if you point your right thumb in the positive direction along an axis as in Figure 13.1, your fingers curl in the counterclockwise directionthe direction in which you measure angles of rotation. Figure 13.2 shows how you should measure angles of rotation around each of the three axes.
Rotation
Rotating an object around an arbitrary line in three dimensions is complicated. Rotating an object around the X, Y, or Z axis, on the other hand, is simple. To rotate a point around the Z axis, for example, simply ignore the Z coordinate of the point and handle the rotation as if it were taking place in two dimensions. Because you are rotating the point around the Z axis, its Z coordinate does not change. The new coordinates for the point are given by the equations:
e10a6a0a59f035e870d90cca05b85fce.gif
new_x = old_x * Cos(q) - old y * Sin(q)
new_y = old_x * Sin(
q) + old y * Cos(q)
new_z = old_z
Table 13.2 shows matrices that rotate a point through an angle q around the three coordinate axes.
Using this information, you can write Visual Basic routines that initialize rotation matrices.
e10a6a0a59f035e870d90cca05b85fce.gif
' Create a 3-D transformation matrix for rotation
' around the X axis (angle measured in radians).
Public Sub m3XRotate(M() As Single, ByVal theta As Single)
Dim i As Integer
Table 13.2 Rotation Transformation Matrices
AROUND THE X AXISAROUND THE Y AXISAROUND THE Z AXIS
z0446-02.gif
z0446-03.gif
z0446-04.gif

 
< previous page page_426 next page >